package org.zch.controller;


import org.springframework.web.bind.annotation.*;
import org.zch.common.ApiResult;
import org.zch.entity.dto.CommentDTO;
import org.zch.entity.po.CommentPO;
import org.zch.entity.dto.WorksDTO;
import org.zch.service.CommentService;
import org.zch.service.ReplyService;

import javax.annotation.Resource;

/**
 * 评论表(Comment)控制层
 *
 * @author 刘新
 * @since 2024-01-11 16:39:55
 */
@RestController
@RequestMapping("comment")
public class CommentController {
    /**
     * 服务对象
     */
    @Resource
    private CommentService commentService;



    /**
     * 发表评论
     *
     * @param commentPO 实体对象
     * @return 新增结果
     */
    @PostMapping("/insert")
    public ApiResult insert(@RequestBody CommentPO commentPO) {
        return ApiResult.ok(this.commentService.insert(commentPO));
    }


    /**
     * 删除评论
     *
     * @param id 主键
     * @return 删除结果
     */
    @PostMapping("/deleteById")
    public ApiResult delete(@RequestParam("id") Integer id) {
        return ApiResult.ok(this.commentService.removeById(id));
    }

    /**
     * 根据作品id，查询评论
     *
     * @param dto 查询条件
     * @return 评论列表
     */
    @PostMapping("/getComment")
    public ApiResult getComment(@RequestBody CommentDTO dto) {
        return ApiResult.ok(this.commentService.getComment(dto));
    }



}

